package Servlet;

import Pojo.NewInfo;
import Service.ViceCheck;
import Service.ViceFindInfo;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/Delect")
public class Delect extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

    }

//    删除新闻
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String id = req.getParameter("id");
        ViceFindInfo viceFindInfo = new ViceFindInfo();
        if(viceFindInfo.delectnew(id)>0){
            ViceCheck viceCheck = new ViceCheck();
//            删除后进行重新加载
            List<NewInfo> newInfo = viceCheck.findinfo(1);
            req.getSession().removeAttribute("newInfo");
            req.getSession().setAttribute("newInfo",newInfo);
            resp.getWriter().print(1);
        }

    }
}
